<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px"
        label-position="left">
        <el-col :span="13">
          <el-form-item label="名称" prop="name">
            <el-input v-model="formData.name" placeholder="请输入名称" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="排序" prop="sortnum">
            <el-input v-model="formData.sortnum" placeholder="请输入序号" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="13">
          <el-form-item label="sku值" prop="skuname">
            <el-input v-model="formData.skuname" placeholder="请输入sku值" clearable :style="{width: '100%'}">
            </el-input><el-button @click="addinput">增加</el-button>
          </el-form-item>
          <el-col v-for="(d,index) in formData.counter" :key="index" :span="13">
            <inputdom></inputdom>
          </el-col>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
export default {
  components: {
    'inputdom':{
          template:'<el-col :span="13"><el-form-item label="sku值" prop="skuname"><el-input v-model="formData.skuname" placeholder="请输入sku值" clearable :style="{width: 100%}"></el-input><el-button @click="addinput">增加</el-button></el-form-item></el-col>'
        },
  },
  props: [],
  data() {
    return {
      formData: {
        name: undefined,
        sortnum: '1',
        skuname: undefined,
        counter:[]
      },
      rules: {
        name: [{
          required: true,
          message: '请输入名称',
          trigger: 'blur'
        }],
        sortnum: [{
          required: true,
          message: '请输入序号',
          trigger: 'blur'
        }],
        skuname: [{
          required: true,
          message: '请输入sku值',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
    addinput(){
        this.formData.counter.push({});
    },
  }
}

</script>
<style>
</style>
